package com.no1.musicmgr.controller;


import com.no1.musicmgr.entity.reCollection;
import com.no1.musicmgr.service.CollectionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;

@Tag(name = "CollectionController", description = "收藏管理模块")
@Controller
@RestController
public class CollectionController {
    @Autowired
    private CollectionService collectionService;

    @Operation(summary = "添加收藏")
    @Parameter(name = "reCollection", description = "收藏对象")
    @PostMapping("/collection")
    public boolean add(Integer music_id,Integer user_id) {
        reCollection reCollection = new reCollection();
        reCollection.setCollectionMusicId(music_id);
        reCollection.setCollectionUserId(user_id);
        return collectionService.insert(reCollection);
    }

    @Operation(summary = "删除收藏")
    @Parameter(name = "collectionId", description = "收藏编号")
    @DeleteMapping("/collection")
    public boolean deleteById(Integer collectionId) {
        return collectionService.deleteById(collectionId);
    }

    @Operation(summary = "修改收藏")
    @Parameter(name = "reCollection", description = "收藏对象")
    @PutMapping("/collection")
    public boolean update(reCollection reCollection) {
        return collectionService.update(reCollection);
    }

    @Operation(summary = "收藏列表")
    @Parameter(name = "reCollection", description = "收藏对象")
    @GetMapping("/collection")
    public Collection<reCollection> list(reCollection reCollection) {
        return collectionService.list(reCollection);
    }


}
